package com.zgkxzx.mvpbase.presenter;

import com.zgkxzx.mvpbase.api.ApiServiceImpl;
import com.zgkxzx.mvpbase.bean.BaseRequestBean;
import com.zgkxzx.mvpbase.model.IGetDataModel;
import com.zgkxzx.mvpbase.model.OnBaseCallBack;
import com.zgkxzx.mvpbase.model.impl.ObtainDataModelImpl;
import com.zgkxzx.mvpbase.utils.Logger;
import com.zgkxzx.mvpbase.view.IMainView;

import rx.Subscriber;

/**
 * 创建者 zgkxzx
 * 日期   2017-04-01
 * 描述   MainPrensenter 协调执行者
 */

public class MainPresenter extends BasePresenter<IMainView> {
    private final static String TAG = MainPresenter.class.getSimpleName();

    private IGetDataModel mGetDataModel;

    /**
     * 构造方法
     */
    public MainPresenter() {
        mGetDataModel = new ObtainDataModelImpl();
    }

    /**
     * 加载presenter
     */
    public void fetch() {

    }


    /**
     * 得到总和
     */
    public void getSumResult() {
        mGetDataModel.getSumResult(new OnBaseCallBack<String>() {
            @Override
            public void onSuccess(String s) {
                if (getView() != null) {
                    getView().display(s);
                }
            }

            @Override
            public void onFailed(String msg) {
                Logger.d(TAG, "onFailed " + msg);
            }
        });

        ApiServiceImpl.uploadWXSport(new Subscriber<BaseRequestBean<String>>() {
            @Override
            public void onCompleted() {
                Logger.d(TAG, "onCompleted " );
            }

            @Override
            public void onError(Throwable e) {
                Logger.d(TAG, "onError "+e );
            }

            @Override
            public void onNext(BaseRequestBean<String> stringBaseRequestBean) {
                Logger.d(TAG, "onNext "+stringBaseRequestBean );
            }
        },"12","2323");

        ApiServiceImpl.uploadWXSport2(new Subscriber<BaseRequestBean<String>>() {
            @Override
            public void onCompleted() {
                Logger.d(TAG, "onCompleted " );
            }

            @Override
            public void onError(Throwable e) {
                Logger.d(TAG, "onError "+e );
            }

            @Override
            public void onNext(BaseRequestBean<String> stringBaseRequestBean) {
                Logger.d(TAG, "onNext "+stringBaseRequestBean );
            }
        },"12","2323");
    }

}
